<?php 

require '../../frame/base.php';
$data = json_decode($_REQUEST['data'],true);

if($data == null){
	echo json_encode(array('code'=>200,'msg'=>'参数异常'));
	exit;

}

foreach ($data as $key => $value) {
	$targetId = explode('-', $value['targetId']);

	$ex = $targetId[0];
	$id = $targetId[1];

	if($ex == 'uid'){
		$result = $Db->table('user')->field('niname,images')->where(array('userid'=>$id))->find();

		// if(!$result){
		// 	echo json_encode(array('code'=>-200,'msg'=>'数据异常'));
		// 	exit;
		// }

	$data[$key]['username'] = $result['niname'];
	$data[$key]['images'] = $result['images'];

	}else if($ex == 'sid'){

		$result = $Db->table('shop')->field('short_name,name,head_pic')->where(array('shopid'=>$id))->find();
		
		// if(!$result){
		// 	echo json_encode(array('code'=>-200,'msg'=>'数据异常'));
		// 	exit;
		// }

		if($result['short_name']){
			$data[$key]['username'] = $result['short_name'];
		}else{
			$data[$key]['username'] = $result['name'];
		}
		
		$data[$key]['images'] = $result['head_pic'];
		

	}


}
	echo json_encode(array('code'=>200,'msg'=>'获取成功','data'=>$data));



 ?>